#include<bits/stdc++.h>
using namespace std;
#define int long long

int mp[10];

signed main() {
	for (int i = 1; i <= 9; i += 2)
		mp[i] = i / 2 + 1;

	string s;
	cin >> s;

	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		ans *= 5;
		ans += mp[s[i] - '0'];
	}
	cout << ans;
	return 0;
}
